import { Bot_msg } from "../../model/bot/bot_msg";
import server from "../../model/client/server";
import func from "../../model/func";
import { mathType, packge } from "../../model/msgHandle/packge";
import { style_default } from "../../style/default";

class index extends packge {

    constructor() {
        super()
    }
    init(): void {
        this.addMath(mathType.math_all, '铁匠铺', ((msg: Bot_msg) => { this.look(msg) }), this,false)
        this.addMath(mathType.math_all, '强化装备', ((msg: Bot_msg) => { server.api('strengthen/Start', {}, msg) }), this,false)
        this.addMath(mathType.math_all, '重铸装备', ((msg: Bot_msg) => {server.api('strengthen/Resetting', {}, msg) }), this,false)
        
    }
    async look(msg: Bot_msg) {
        let req = await server.api('strengthen/Look', {}, msg);
        if (!req) {
            return;
        }
        func.roundNumbers(req)
        let s = new style_default();
        s.setTitle('铁匠铺','⚙️');
        s.addLine(`📄${req.equip.name}Lv.${req.equip.leve}`);
        s.addLine(`⭐️评分:${req.equip.score}`);
        s.addLine(`🔎来源:${req.equip.from}`);
        s.setline_Title(`强化信息`,'⚙️')
        if(req.succ >= 100){
            req.succ = 100;
        }else{
            req.succ = Math.floor(req.succ);
        }
        s.addLine(`🙏成功率:${req.succ}%`);
        if (req.down > 0) {
            s.addLine(`😭掉级率:${req.down}`);
        }
        
        s.addLine(`💰️强化需要:${req.need_strengthen}`);
        s.addLine('🔨确认强化发送[强化装备]');
        s.setline_Title(`重铸信息`,'⚙️')
        s.addLine(`💰️重铸需要:${req.need_resting}`);
        s.addLine('🔨确认重铸发送[重铸装备]');
        msg.repeText(s.end())
    }
}
export default new index();